package model;

import java.util.ArrayList;
import java.util.List;


public class Bag {

    private List<Card> listCards = new ArrayList<Card>();

    /**
     * Select a card randomly
     * @return : A random card
     */
    public Card getRandomCard () {
        double rdm = Math.random();
        int max = listCards.size() - 1;
        int choice = (int)(Math.round(rdm*max));
        Card c = null;
        //System.out.println("Bag | Taille du tableau : "+max);
        //System.out.println("Bag | Carte demandée : "+choice);
        
        try
        {
            c = listCards.get(choice);
            listCards.remove(choice);
        }
        catch(IndexOutOfBoundsException e)
        {
            System.err.println("Taille du sac : " + listCards.size() + " / Choix : " + choice);
        }
        
        return c;
    }
    
    /***************************** GETTERS & SETTERS **************************/

    public List<Card> getListCards () {
        return listCards;
    }
}

